package com.qingchunlin.springprinciple;

import com.qingchunlin.springprinciple.component.BeanLifeComponent;
import com.qingchunlin.springprinciple.entity.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringPrincipleApplication {

    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(SpringPrincipleApplication.class, args);

        //只能根据类寻找一个,如果有两个一样的,那么就会找不到
        //User user1 = applicationContext.getBean(User.class);
        //System.out.println(user1);

//        User user1 = (User) applicationContext.getBean("user1");
//        User user2 = (User) applicationContext.getBean("user2");
//        System.out.println(user1);
//        System.out.println(user2);

        BeanLifeComponent beanLifeComponent = applicationContext.getBean(BeanLifeComponent.class);
        beanLifeComponent.use();
    }

}
